console.log("hellofunc")


abs(3);

// 参数不用写类型,返回值类型也可以不用写  whatfuck 
function abs(x) {
    console.log(x)
    if (x >= 0) {
        return x;
    } else {
        return -x;
    }
}

// 属于匿名函数，结尾要加；
var abs = function (x) {
    if (x >= 0) {
        return x;
    } else {
        return -x;
    }
};


function foo(x) {
    console.log('x = ' + x);
}

function foo(a, b) {
    var i, rest = [];
    if (arguments.length > 2) {
        for (i = 2; i < arguments.length; i++) {
            rest.push(arguments[i]);
        }
    }
    console.log('a = ' + a);
    console.log('b = ' + b);
    console.log(rest);
}



function foo1(a, b, ...rest) {
    console.log('a = ' + a);
    console.log('b = ' + b);
    console.log(rest);
}

foo(2, 3, 5, 9, 90);
foo1(2, 3, 5, 9, 92220)




function food() {
    return { name: 'foo' };
}

food();


function foo() {
    var x = 1;
    x = x + 1;
}

x = x + 2; // ReferenceError! 无法在函数体外引用变量x